# （3）新建“exerc3”Python文件完成作业，系统随机生成8个1-33的整数形成一注中奖号码，用户在控制台输入8位数字看是否中奖：
# 号码全对：一等奖
# 错一个：二等奖
# 错两个：三等奖
# 错三个：四等奖


import random
def generate_lottery_numbers():
    return [random.randint(1, 33) for _ in range(8)]
def check_prize(user_numbers, winning_numbers):
    correct = sum(1 for u, w in zip(user_numbers, winning_numbers) if u == w)
    if correct == 8:
        return "一等奖"
    elif correct == 7:
        return "二等奖"
    elif correct == 6:
        return "三等奖"
    elif correct == 5:
        return "四等奖"
    else:
        return "未中奖"
winning_numbers = generate_lottery_numbers()
user_numbers = list(map(int, input("请输入8个数字（1-33）: ").split()))

print(f"中奖号码: {winning_numbers}")
print(f"您的号码: {user_numbers}")
print(f"中奖结果: {check_prize(user_numbers, winning_numbers)}")

# 模拟10000注彩票中奖概率
target_numbers = [1, 2, 3, 4, 5, 6, 7, 8]  # 特定号码
wins = 0
for _ in range(10000):
    if check_prize(target_numbers, generate_lottery_numbers()) != "未中奖":
        wins += 1
print(f"特定号码的中奖概率: {wins / 10000 * 100}%")